home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / DOC.PAK / RESFMT.TXT < prev    next >
Text File  |  1997-05-06  |  46KB  |  1,135 lines

  1.  
  2.  Win32 Binary Resource Formats
  3.  
  4.  Author:  Floyd Rogers
  5.  
  6.  
  7.  Preface
  8.  
  9.  This document was edited and released by Microsoft Developer
  10.  Support. It describes the binary format of resources in Win32. The
  11.  information is provided at this point because we feel it will make
  12.  the work of application development easier. Unfortunately, the
  13.  information in this document may change before the final release of
  14.  Windows NT. Microsoft is NOT committing to stay with these formats
  15.  by releasing this document. Questions or follow-ups for any of the
  16.  information presented here should be posted to CompuServe MSWIN32
  17.  forum, section 4.
  18.                     --Steve Firebaugh
  19.                       Microsoft Developer Support
  20.  
  21.  
  22. 1. Overview
  23.     1.1 Comparison to Windows 16 (Win 3.0/3.1)
  24.     1.2 Strings in UNICODE
  25.     1.3 DWORD Alignment
  26. 2. General information
  27.     2.1 New Statements
  28.     2.1.1 New Button statements
  29.         2.1.1.1 AUTO3STATE
  30.         2.1.1.2 AUTOCHECKBOX
  31.         2.1.1.3 AUTORADIOBUTTON
  32.         2.1.1.4 PUSHBOX
  33.         2.1.1.5 STATE3 (3STATE)
  34.         2.1.1.6 USERBUTTON
  35.     2.1.2 EXSTYLE statement
  36.     2.1.3 CHARACTERISTICS statement
  37.     2.1.4 VERSION statement
  38.     2.1.5 LANGUAGE statement
  39.     2.1.6 MESSAGETABLE statement
  40.     2.1.6 Additional syntax for UNICODE strings.
  41. 3. Resource Header Format
  42.     3.1 DataSize
  43.     3.2 HeaderSize
  44.     3.3 Type
  45.     3.4 Names
  46.     3.5 Additional Resource Header Information
  47.         3.5.1 DataVersion
  48.         3.5.2 MemoryFlags
  49.         3.5.3 LanguageId
  50.         3.5.4 Version and Characteristics
  51.     3.6 Differentiating 16 and 32-bit resource files
  52.     3.7 File alignment
  53. 4. Resource Data Format
  54.     4.1 Version Resources
  55.     4.2 Icon Resources
  56.     4.3 Menu Resources
  57.     4.4 Dialog Box Resources
  58.     4.5 Cursor Resources
  59.     4.6 Bitmap Resources
  60.     4.7 Font and Font Directory Resources
  61.     4.8 String Table Resources
  62.     4.9 Accelerator Table Resources
  63.     4.10 User Defined Resources and RCDATA
  64.     4.11 Name Table and Error Table Resources
  65.     4.12 Version Resourses
  66.     4.13 Messagetable Resources
  67. 5. Revision History
  68.  
  69.  
  70.  
  71.  
  72. 1. Overview
  73.  
  74. This document details the structure of the resource binary file
  75. (.res) format for the Windows 32 API (Windows NT 3.1 and Win32s).
  76. The structure is similar to the existing Windows 16 (Win 3.0/3.1)
  77. structure, but supports essential new features such as UNICODE
  78. strings, version headers, and DWORD alignment.  To support these
  79. changes, the file format written by the resource compiler must be
  80. changed from that used by Windows 16.
  81.  
  82. 1.1 Comparison between Windows 3.0/3.1 and Windows 32
  83.  
  84. The Windows 16 resource file is a file containing one or more binary
  85. resources.  Each resource is preceded by a variable length structure
  86. containing:  Type, Name, Flags, Size.  The Type and Name fields are
  87. either a string identifying the Type or Name, or a WORD value
  88. specifying the ordinal identity of the resource.  The Flags field
  89. specifies to the system how to load into memory the resource, and the
  90. size specifies the size in bytes of the resource.  The size,
  91. therefore, points to the next resource in the file.
  92.  
  93. The Windows 32 (both NT and Win32s) resource file retains this
  94. structure, while expanding the header information with several
  95. additional values.  It also adds a few fields to some of the pre-
  96. defined resources (Menu and Dialog, for instance), aligns all fields
  97. within the predefined resources on WORD or DWORD boundaries, and adds
  98. UNICODE (16-bit character) support to the data structures.
  99.  
  100. One additional difference in resource files for Windows 32 is worth
  101. noting.  This does not directly affect the structure of the resource
  102. file, but is rather a difference in how resource files are handled
  103. and incorporated into an executable image (dll or exe).  Windows NT
  104. uses COFF format objects.  Because of this, and the fact that the
  105. Windows 32 exe format is much different than the Windows 16 format,
  106. the SDK provides a utility named CVTRES that converts a resource file
  107. into a COFF object.  The linker then incorporates this object
  108. directly into the resulting executable image.  No provision is made
  109. (as in Windows 16) for running the second pass of the resource
  110. compiler multiple times to update the resources:  relinking the image
  111. is required.
  112.  
  113. However, the Windows 32 API provides a set of APIs that allow a
  114. program to enumerate all resources within an executable image, and
  115. update individual resources in the image.
  116.  
  117. 1.2 Strings in UNICODE
  118.  
  119. All strings in a resource file are now stored in UNICODE format.  In
  120. this format, all characters are represented by a 16-bit (WORD) value.
  121. The first 128 characters are identical to the 128 characters in the
  122. Windows ANSI character set (although the characters are represented
  123. by 16 bits each rather than 8bits).  The characters in positions 160-
  124. 254 are similar to the characters in the standard Windows character
  125. set (note that the characters 128-159 are illegal Unicode
  126. codepoints).  This means that they are terminated with a UNICODE_NULL
  127. symbol rather than a single NULL.  The resource compiler translates
  128. all normal ASCII strings into UNICODE by calling the
  129. MultiByteToWideChar function provided by the Windows API.  All
  130. escaped characters are stored directly, and are assumed to be valid
  131. UNICODE characters for the resource.  If these strings are read in
  132. later by an application as ASCII (for instance, by calling the
  133. LoadString api), they will be converted back from UNICODE to ASCII
  134. transparently by the loader.
  135.  
  136. The only exception to the rule is strings in RCDATA statements.
  137. These psuedo-strings are not real strings, but merely a convenient
  138. notation for a collection of bytes.  Users may overlay a structure
  139. over the data from an RCDATA statement, and expect certain data to be
  140. at certain offsets.  If a psuedo-string gets automatically changed
  141. into a UNICODE string, it things would inadvertently change the
  142. offsets of things in the structure and break those applications.
  143. Hence, these psuedo-strings must be left as ASCII bytes.  To specify
  144. a UNICODE string inside an RCDATA statement, the user should use the
  145. explicit L-quoted string.
  146.  
  147. 1.3 DWORD Alignment
  148.  
  149. To make resource binary files easier to read under Windows 32, all
  150. objects within the file are to be DWORD aligned.  This includes
  151. headers, as well as data entries.  This does not usually entail
  152. changes in the order of the fields of resource data structures, but
  153. does entail the need for some padding between fields.
  154.  
  155. The single exception to this rule is the font and fontdir structures.
  156. The reason for the exception is that these two structures are copied
  157. directly from other files, and are not used by RC.
  158.  
  159. 2.  General information
  160.  
  161. The resource file is created by the resource compiler (RC) while
  162. parsing the resource script file (.RC) and including any other
  163. resource data files (eg. .ICO, .CUR, .BMP, .FNT).  The resource file
  164. contains all information necessary to build the resource table in the
  165. executable image.  The main purpose of the resource file is to speed
  166. the edit-compile-link cycle by not always forcing resource to be
  167. recompiled.
  168.  
  169. There are currently about a dozen pre-defined resource types.  These
  170. include Menus, Dialogs, Accelerators, Strings, Icons, Cursors,
  171. Bitmaps, Fonts and Version.  These resources are used by the Windows
  172. system to define the appearance of the application window.  The
  173. resource script allows the application writer to represent these
  174. features in an easily editable form.  Other type ranges are reserved
  175. for use by the application for application-specific data.  No attempt
  176. is made by the resource compiler to modify this user-defined data
  177. from 16-bit to 32-bit format.
  178.  
  179. The executable image file for Windows 32 is not a Segmented image.
  180. In the 16-bit executable image file, each resource was placed into a
  181. separate segment in the image file.  The Windows 32 image file places
  182. all resources into a single Object or section.  The Windows 32 image
  183. file also provides a binary-sorted resource table that allows fast
  184. lookup of a particular resource, rather than a table that must be
  185. searched linearly, as in the 16-bit image file.  Because this Windows
  186. 32 image file format is more complex that the Windows 16 format,
  187. making it harder to update directly, the Windows 32 API provides
  188. methods of modifying the resource data directly.
  189.  
  190. The CVTRES conversion utility that converts the resource file into a
  191. COFF object creates the resource table.  This table contains three
  192. directories, indexed by Type, Name and Language, in that order.  The
  193. Type and Name directories consist of two parts:  the part dedicated
  194. to resources whose types or names are represented by strings, an
  195. those represented by ordinal WORD values.  Because the use of strings
  196. as resource type and name identifiers takes considerably more room
  197. than ordinal identifiers, Microsoft recommends that they not be used.
  198.  
  199. Note that, as all strings in a resource file (including the strings
  200. used to identify the type and name of resources) are UNICODE, the
  201. corresponding strings in the program that are being passed to
  202. LoadBitmap, etc., must also be UNICODE (only if the application is
  203. using the UNICODE set of apis rather than the ASCII set).  This is
  204. facilitated by use of the TEXT macro provided in winnt.h.
  205.  
  206. The third level, language, provides the capability for the
  207. application developer to ship a single executable image that supports
  208. more than one language.  For instance, one image providing French,
  209. French-Canadian and French-Belgium could be easily shipped in one
  210. image file.  An application could also be shipped with support for
  211. all languages supported by the UNICODE standard, although this would
  212. make the image prohibitively large.  However, since the system
  213. provides facilities to modify the resources within an image, a setup
  214. program could customize the application's image file for each
  215. specific user, eliminating unneeded language support to save space in
  216. the image file.
  217.  
  218. 2.1 New statements
  219.  
  220. Several new statements have been added that the Windows 32 resource
  221. compiler processes.
  222.  
  223. 2.1.1 New Button statements.
  224.  
  225. These statements allow the application developer the same freedom of
  226. expression that the PUSHBUTTON, DEFPUSHBUTTON, etc., statements do,
  227. and correspond to the appropriate button style.
  228.  
  229. They all have syntax identical to that of PUSHBUTTON, etc.
  230.  
  231. 2.1.1.1 AUTO3STATE
  232.  
  233. Allows declaration of an AUTO3STATE button.
  234.  
  235. 2.1.1.2 AUTOCHECKBOX
  236.  
  237. Allows declaration of an AUTOCHECKBOX button.
  238.  
  239. 2.1.1.3 AUTORADIOBUTTON
  240.  
  241. Allows declaration of an AUTORADIOBUTTON button.
  242.  
  243. 2.1.1.5 PUSHBOX
  244.  
  245. Allows declaration of a PUSHBOX button.
  246.  
  247. 2.1.1.6 STATE3
  248.  
  249. Allows declaration of a 3STATE button (the 3 is at the end for syntax
  250. purposes).
  251.  
  252. 2.1.1.7 USERBUTTON
  253.  
  254. Allows declaration of a USERBUTTON user-defined button.
  255.  
  256. 2.1.2 EXSTYLE statement
  257.  
  258. This statement allows the application developer to designate one of
  259. the extended (WS_EX_xxx) styles for a dialog or control window.
  260. There are three methods, depending upon what is needed.
  261.  
  262. It may be placed just below the DIALOG statement to apply to the
  263. dialog window (like the CAPTION or STYLE statements).
  264.  
  265.      EXSTYLE <flags>
  266.      
  267. It may be placed on the DIALOG statement with the memory flags.
  268.  
  269.      FOOBAR DIALOG [MemFlags...] [EXSTYLE=<flags>] x, y, dx, dy
  270.      
  271. It may also be placed on the individual CONTROL, PUSHBUTTON, LTEXT,
  272. etc. statements at the end of the statement.
  273.  
  274.      AUTOCHECKBOX "autocheckbox", id, x, y, dx, dy
  275.      [styleflags][exstyleflags]
  276.      
  277. 2.1.3 CHARACTERISTICS statement
  278.  
  279. This statement allows the application developer to specify
  280. information about the resource that may be of use to tools that read
  281. and write resource files.  It has no significance to the system and
  282. is not stored in the image file.
  283.  
  284.      CHARACTERISTICS <user defined DWORD value>
  285.      
  286. 2.1.4 VERSION statement
  287.  
  288. This statement is intended to allow the application to specify a
  289. version number of the resource in the resource file (for those tools
  290. that read and write resource files.)  It has no significance to the
  291. system and is not stored in the image file.
  292.  
  293.      VERSION <user defined DWORD value>
  294.      
  295. 2.1.5 LANGUAGE statement
  296.  
  297. The LANGUAGE statement is used to specify the language the resource
  298. file, or section of resource file, is written in.  It may be placed
  299. anywhere within the resource script file that a single-line statement
  300. (such as ICON, CURSOR, BITMAP) may be placed.  The scope of the
  301. language specified by a LANGUAGE statement is from that point in the
  302. script file to the next LANGUAGE statement, or the end of the file.
  303.  
  304.      LANGUAGE <majornumber>,<minornumber>
  305.      
  306. where <majornumber> represents the language id, and <minornumber> the
  307. sub-language identifiers.  The values specified in winnt.h should be
  308. used.
  309.  
  310. The LANGUAGE statement may also be placed before the BEGIN statement
  311. for MENU, DIALOG, STRINGTABLE, ACCELERATOR and RCDATA resources,
  312. along with other optional statements like CAPTION, STYLE, etc.  If
  313. the statement is placed here, it's scope is limited to the resource
  314. being defined.
  315.  
  316. 2.1.6 MESSAGETABLE statement
  317.  
  318. The MESSAGETABLE statement is used to include a message table.  A
  319. message table is a special-purpose string table that is used to
  320. contain error or informational messages, and may contain formatting
  321. information.  The format is:
  322.  
  323.      <nameid> MESSAGETABLE <filename>
  324.      
  325. 2.1.7 Additional syntax for UNICODE strings.
  326.  
  327. Quoted strings in the resource script are treated as ASCII strings
  328. (in the current codepage) unless preceeded by a "L" or "l" character,
  329. eg:
  330.      L"This is a Unicode string"
  331. Declaring a string UNICODE with this syntax has two effects.  In a
  332. RCDATA statement, this causes the compiler to store the string as
  333. UNICODE rather than ASCII.  In all cases using this syntax, escapes
  334. embedded within the string become UNICODE codepoint escapes resulting
  335. in a 16-bit UNICODE character, eg:
  336.      L"This is the first line,\x2028and this is the second"
  337. where the 0x2028 UNICODE character is the Line Separator character.
  338. Any UNICODE character may be embedded within any resource script
  339. string in this manner.
  340.  
  341. 3. Resource Header Format
  342.  
  343. The general format of the entire file is simply a number of resource
  344. file entries concatenated together.  Each resource contains the
  345. information about a single resource, such as a dialog or a string
  346. table.
  347.  
  348. Each entry consists of a resource header followed by the data for
  349. that resource.  A resource header (which is DWORD aligned) is
  350. composed of four elements: two dwords containing the size of the
  351. header and the size of the resource data, the resource type, the
  352. resource name, and additional resource information.  The data for the
  353. resource follows the resource header and is specific to each
  354. particular type of resource.
  355.  
  356. 3.1 DataSize
  357.  
  358. This field gives the size of the data that follows the header, not
  359. including any file padding between this resource and any resource
  360. that follows this resource in the resource file.
  361.  
  362. 3.2 HeaderSize
  363.  
  364. The HeaderSize field gives the size of the resource header structure
  365. that follows.
  366.  
  367. 3.3 Type
  368.  
  369. The type field can either be a number or a null-terminated UNICODE
  370. string specifying the name of the type.  This variable kind of type
  371. is known as a `Name or Ordinal' field, and is used in most places in
  372. a resource file where an ID may appear.
  373.  
  374. The first WORD of a Name or Ordinal field identifies whether the
  375. field is a number or a string.  If the first WORD is 0xffff (an
  376. invalid UNICODE character), then the following WORD of information is
  377. the type number.  Otherwise, the field is specified by a UNICODE
  378. string.
  379.  
  380. If the type field is a number, then the number specifies a standard
  381. or user-defined resource type.  All standard Windows resource types
  382. have been assigned numbers, which are listed below.  This list is
  383. taken from the header file used to make RC and contains the type
  384. number of the various resource types:
  385.  
  386.     /* Predefined resource types */
  387.     #define    RT_NEWRESOURCE      0x2000
  388.     #define    RT_ERROR            0x7fff
  389.     #define    RT_CURSOR           1
  390.     #define    RT_BITMAP           2
  391.     #define    RT_ICON             3
  392.     #define    RT_MENU             4
  393.     #define    RT_DIALOG           5
  394.     #define    RT_STRING           6
  395.     #define    RT_FONTDIR          7
  396.     #define    RT_FONT             8
  397.     #define    RT_ACCELERATORS     9
  398.     #define    RT_RCDATA           10
  399.     #define    RT_MESSAGETABLE     11
  400.     #define    RT_GROUP_CURSOR     12
  401.     #define    RT_GROUP_ICON       14
  402.     #define    RT_VERSION          16
  403.     #define    RT_NEWBITMAP        (RT_BITMAP|RT_NEWRESOURCE)
  404.     #define    RT_NEWMENU          (RT_MENU|RT_NEWRESOURCE)
  405.     #define    RT_NEWDIALOG        (RT_DIALOG|RT_NEWRESOURCE)
  406.     
  407. If the type field is a string, then the type is a user-defined type.
  408.  
  409. 3.4 Names
  410.  
  411. A name identifies the particular resource.  A name (like a type) may
  412. be a number or a string, and they are distinguished in the same way
  413. as numbers and strings are distinguished in the type field.
  414.  
  415. Note that no padding (for DWORD alignment) is needed between the Type
  416. and Name fields, as they contain only WORD data and hence the Name
  417. field will always be properly aligned.  However, there may need to be
  418. a WORD of padding after the Name field to align the rest of the
  419. header on DWORD boundaries.
  420.  
  421. 3.5 Additional Header Information
  422.  
  423. The additional information contains more information about the
  424. particular resource data, including size and language ID.  The
  425. structure of the Header, plus it's additional information is as
  426. follows:
  427.  
  428. struct tagResource {
  429.   DWORD  DataSize;           // size of data without header
  430.   DWORD  HeaderSize;         // Length of the additional header
  431.   [Ordinal or name TYPE]     // type identifier, id or string
  432.   [Ordinal or name NAME]     // name identifier, id or string
  433.   DWORD  DataVersion;        // predefined resource data version
  434.   WORD   MemoryFlags;        // state of the resource
  435.   WORD   LanguageId;         // UNICODE support for NLS
  436.   DWORD  Version;            // Version of the resource data
  437.   DWORD  Characteristics;    // Characteristics of the data
  438.   } ;
  439.     
  440. The additional information structure will always begin on a DWORD
  441. boundary within the resource file, which may require adding some
  442. padding in between the name field and the ResAdditional structure.
  443.  
  444. 3.5.1 DataVersion
  445.  
  446. The DataVersion field determines the format of the information
  447. within the resource header that follows. This may be used in the
  448. future to allow additional information to be entered into the
  449. predefined formats.
  450.  
  451. 3.5.2 MemoryFlags
  452.  
  453. The field wMemoryFlags contains flags telling the state of a given
  454. resource.  These attributes are given to a given resource by
  455. modifiers in the .RC script.  The script identifiers inject the
  456. following flag values:
  457.  
  458.     #define    MOVEABLE            0x0010
  459.     #define    FIXED               ~MOVEABLE
  460.     #define    PURE                0x0020
  461.     #define    IMPURE              ~PURE
  462.     #define    PRELOAD             0x0040
  463.     #define    LOADONCALL          ~PRELOAD
  464.     #define    DISCARDABLE         0x1000
  465.     
  466. The resource compiler for NT always ignores the setting of the
  467. MOVEABLE, IMPURE, and PRELOAD flags.
  468.  
  469. 3.5.3 LanguageId
  470.  
  471. The language ID is included in each resource to specify the language
  472. that the strings are written with when they need to be translated
  473. back to a single byte strings.  As well, there may be multiple
  474. resources of exactly the same type and name which differ in only the
  475. language of the strings within the resources.
  476.  
  477. The language IDs are documented in Appendix A of the NLS
  478. specification, or in winnt.h.  The language of a resource or set of
  479. resources is specified by the LANGUAGE statement.
  480.  
  481. 3.5.4 Version and Characteristics
  482.  
  483. Currently, there is space in the resource file format for version and
  484. characteristic information of the resource.  These values can be set
  485. by the resource compiler by using the VERSION or CHARACTERISTICS
  486. statements.
  487.  
  488. 3.6 Differentiating 16 and 32-bit resource files.
  489.  
  490. Because it might be desirable for an ISV's tool that reads and writes
  491. resource files to be able to read either the older Windows 16 format
  492. files and the new Windows 32 format, Microsoft has devised a method
  493. to do this using illegal type and name ordinal numbers.
  494.  
  495. The method involved is to place an illegal resource in the resource
  496. file.  The following eight bytes were chosen:
  497.  
  498.      0x00 0x00 0x00 0x00 0x20 0x00 0x00 0x00
  499.      
  500. Assume that it is a 16-bit file.  In that case, the Type is illegal
  501. since the first 0x00 says string, but a zero-length string is an
  502. illegal string.  This, then is an illegal 16-bit resource header,
  503. indicating that the file is a 32-bit file.
  504.  
  505. Assume that it is a 32-bit file.  Given that, the size of the data is
  506. zero, which surely will never be the case.
  507.  
  508. The Windows 32 resource compiler prefaces each 32-bit resource file
  509. with this string of data (followed by an additional data structure
  510. describing a zero-length resource with 0 ordinal type and 0 ordinal
  511. name), allowing differentiation of 16 and 32-bit resource files.  Any
  512. tools reading resource files should ignore this resource.
  513.  
  514. 3.7 File Alignment.
  515.  
  516. Because it is sometimes useful to separate resources into several
  517. scripts and then concatenate them after compiling the resource files
  518. separately, it is necessary to specify that resource files are padded
  519. to a dword size.  If this padding were not included, it could result
  520. in the first resource of the second and/or subsequent resource files
  521. not aligning upon a dword boundary.
  522.  
  523. 4.  Resource Data Format
  524.  
  525. For any of the pre-defined data types, all structures are DWORD
  526. aligned, including the bitmap, icon, and font header structures.  As
  527. well, the data will always begin on a DWORD boundary.
  528.  
  529. 4.1 Version Resources
  530.  
  531. Version resources are used to record the version of the application
  532. using the resource file.  Version resources contain a fixed amount of
  533. information.  The structure of the version resource is as follows:
  534.  
  535. typedef struct tagVS_FIXEDFILEINFO {
  536.   DWORD  dwSignature;        // e.g.  0xfeef04bd
  537.   DWORD  dwStrucVersion;     // e.g.  0x00000042 = "0.42"
  538.   DWORD  dwFileVersionMS;    // e.g.  0x00030075 = "3.75"
  539.   DWORD  dwFileVersionLS;    // e.g.  0x00000031 = "0.31"
  540.   DWORD  dwProductVersionMS; // e.g.  0x00030010 = "3.10"
  541.   DWORD  dwProductVersionLS; // e.g.  0x00000031 = "0.31"
  542.   DWORD  dwFileFlagsMask;    // = 0x3F for version "0.42"
  543.   DWORD  dwFileFlags;        // e.g.  VFF_DEBUG | VFF_PRERELEASE
  544.   DWORD  dwFileOS;           // e.g.  VOS_DOS_WINDOWS16
  545.   DWORD  dwFileType;         // e.g.  VFT_DRIVER
  546.   DWORD  dwFileSubtype;      // e.g.  VFT2_DRV_KEYBOARD
  547.   DWORD  dwFileDateMS;       // e.g.  0
  548.   DWORD  dwFileDateLS;       // e.g.  0
  549.   } VS_FIXEDFILEINFO;
  550.  
  551. 4.2 Icon Resources
  552.  
  553. The ICON statement in the .RC script does not create a single
  554. resource object, but creates a group of resources.  This allows
  555. Windows programs a degree of device-independence through the use of
  556. different pixel bitmaps on hardware configurations with differing
  557. capabilities.  Icons, most often designed for differing numbers of
  558. pixel planes and pixel counts, are grouped and treated by Windows as
  559. a single resource.  In the .RES and .EXE files, however, they are
  560. stored as a group of resources.  These groups are stored in a .RES
  561. file with the components first (in this case the different icons
  562. [type 3]) and a group header following (Type 14).  The group header
  563. contains the information necessary to allow Windows to select the
  564. proper icon to display.
  565.  
  566. The components have the following structure:
  567.  
  568.         [Resource header (type = 3)]
  569.     
  570.         [DIB Header]
  571.         [Color DIBits of icon XOR mask]
  572.         [Monochrome DIBits of AND mask]
  573.     
  574. Each component is given an ordinal ID that is unique from all other
  575. icon components.
  576.  
  577. The Device Independent Bitmap (DIB) header's fields represent the
  578. masks' information separately with two exceptions.  First, the height
  579. field represents both the XOR and AND masks.  Before converting the
  580. two DIBs to Device Dependent Bitmaps (DDB), the height should be
  581. divided by two.  The masks are always the same size and are one-half
  582. the size given in the DIB header.  Second, the number of bits per
  583. pixel and bit count refer to the XOR mask.  The AND mask is always
  584. monochrome and should be interpreted as having one plane and one bit
  585. per pixel.  Before using an icon with Windows refer to the SDK
  586. reference materials for more information on DIBs.  Since the format
  587. of an icon component closely resembles the format of the .ICO file,
  588. the documentation in section 9.2 of the Windows SDK Reference is
  589. useful.  DDBs should not be used for Windows 32 applications.
  590.  
  591. The group header is described here:
  592.  
  593.     [Resource header (type = 14)]
  594.     
  595. struct IconHeader {
  596.   WORD   wReserved;          // Currently zero
  597.   WORD   wType;              // 1 for icons
  598.   WORD   wCount;             // Number of components
  599.   WORD   padding;            // filler for DWORD alignment
  600.   };
  601.   
  602. The next portion is repeated for each component resource:
  603.  
  604. struct ResourceDirectory {
  605.   BYTE   bWidth;
  606.   BYTE   bHeight;
  607.   BYTE   bColorCount;
  608.   BYTE   bReserved;
  609.   WORD   wPlanes;
  610.   WORD   wBitCount;
  611.   DWORD  lBytesInRes;
  612.   WORD   wNameOrdinal;       // Points to component
  613.   WORD   padding;            // filler for DWORD alignment
  614.   };
  615.     
  616. Notice that the group header consists of a fixed header and data that
  617. repeats for each group component.  Both of these parts are fixed
  618. length allowing for random access of the group component information.
  619.  
  620. This group header contains all of the data from the .ICO header and
  621. from the individual resource descriptors.
  622.  
  623. 4.3 Menu Resources
  624.  
  625. Menu resources are composed of a menu header followed by a sequential
  626. list of menu items.  There are two types of menu items:  popups and
  627. normal menu items.  The MENUITEM SEPARATOR is a special case of a
  628. normal menu item with an empty name, zero ID, and zero flags.  The
  629. format for these types is shown here:
  630.  
  631.     [Resource header (type = 4)]
  632.     
  633. struct MenuHeader {
  634.   WORD   wVersion;           // Currently zero
  635.   WORD   cbHeaderSize;       // Also zero
  636.   };
  637.     
  638. These next items are repeated for every menu item.
  639.  
  640. Popup menu items (signalled by fItemFlags & POPUP):
  641.  
  642. struct PopupMenuItem {
  643.   WORD   fItemFlags;
  644.   WCHAR  szItemText[];
  645.   };
  646.     
  647. Normal menu items (signalled by !(fItemFlags & POPUP)):
  648.  
  649. struct NormalMenuItem {
  650.   WORD   fItemFlags;
  651.   WORD   wMenuID;
  652.   WCHAR  szItemText[];
  653.   };
  654.     
  655. The wVersion and cbHeaderSize structure members identify the version
  656. of the menu template.  They are both zero for Windows 3.0 but may be
  657. incremented with future changes to the menu template.
  658.  
  659. The WORD fItemFlags is a set of flags describing the menu item.  If
  660. the POPUP bit is set, the item is a POPUP.  Otherwise, it is a normal
  661. menu component.  There are several other flag bits that may be set.
  662. Their values are as follows:
  663.  
  664.     #define    GRAYED         0x0001   // 'GRAYED' keyword
  665.     #define    INACTIVE       0x0002   // 'INACTIVE' keyword
  666.     #define    BITMAP         0x0004   // 'BITMAP' keyword
  667.     #define    OWNERDRAW      0x0100   // 'OWNERDRAW' keyword
  668.     #define    CHECKED        0x0008   // 'CHECKED' keyword
  669.     #define    POPUP          0x0010   // Used internally
  670.     #define    MENUBARBREAK   0x0020   // 'MENUBARBREAK' keyword
  671.     #define    MENUBREAK      0x0040   // 'MENUBREAK' keyword
  672.     #define    ENDMENU        0x0080   // Used internally
  673.     
  674. The fItemFlags portion of the last menu item in a given POPUP is
  675. flagged by OR'ing it with ENDMENU.  It is important to note that
  676. since popups can be nested, there may be multiple levels of items
  677. with ENDMENU set.  When menus are nested, the items are inserted
  678. sequentially.  A program can traverse this hierarchy by checking for
  679. the item with the ENDMENU flag set.
  680.  
  681. 4.4 Dialog Box Resources
  682.  
  683. A dialog box is contained in a single resource and has a header and a
  684. portion repeated for each control in the dialog box.  The header is
  685. as follows:
  686.  
  687.     [Resource header (type = 5)]
  688.     
  689. struct DialogBoxHeader {
  690.   DWORD  lStyle;
  691.   DWORD  lExtendedStyle;     // new for NT
  692.   WORD   NumberOfItems;
  693.   WORD   x;
  694.   WORD   y;
  695.   WORD   cx;
  696.   WORD   cy;
  697.   [Name or Ordinal] MenuName;
  698.   [Name or Ordinal] ClassName;
  699.   WCHAR  szCaption[];
  700.   WORD   wPointSize;         // Only here if FONT set for dialog
  701.   WCHAR  szFontName[];       // This too
  702.   };
  703.   
  704. The item DWORD lStyle is a standard window style composed of flags
  705. found in WINDOWS.H.    The default style for a dialog box is:
  706.  
  707.     WS_POPUP | WS_BORDER | WS_SYSMENU
  708.     
  709. The lExtendedStyle DWORD is used to specify the extended window style
  710. flags.  If an extended style is specified on the DIALOG statement, or
  711. with the other optional modifier statements, this DWORD is set to
  712. that value.
  713.  
  714. The items marked `Name or Ordinal' are the same format used
  715. throughout the resource file (most notably in each resource header)
  716. to store a name or an ordinal ID.  As before, if the first byte is an
  717. 0xffff, the next two bytes contain an ordinal ID.  Otherwise, the
  718. first 1 or more WORDS contain a null-terminated string.  An empty
  719. string is represented by a single WORD zero in the first location.
  720.  
  721. The WORD wPointSize and WCHAR szFontName entries are present if the
  722. FONT statement was included for the dialog box.  This can be detected
  723. by checking the entry lStyle.  if lStyle & DS_SETFONT (DS_SETFONT =
  724. 0x40), then these entries will be present.
  725.  
  726. The data for each control starts on a DWORD boundary (which may
  727. require some padding from the previous control), and its format is as
  728. follows:
  729.  
  730. struct ControlData {
  731.   DWORD  lStyle;
  732.   DWORD  lExtendedStyle;
  733.   WORD   x;
  734.   WORD   y;
  735.   WORD   cx;
  736.   WORD   cy;
  737.   WORD   wId;
  738.   [Name or Ordinal] ClassId;
  739.   [Name or Ordinal] Text;
  740.   WORD   nExtraStuff;
  741.   };
  742.     
  743. As before, the item DWORD lStyle is a standard window style composed
  744. of the flags found in WINDOWS.H.  The type of control is determined
  745. by the class.  The class is either given by a zero-terminated string,
  746. or in the case of many common Windows classes, is given a one word
  747. code to save space and speed processing.  Because UNICODE allows
  748. 0x8000 as a legal character, the ordinal classes are prefaced with a
  749. of 0xFFFF, similar to the ordinal Type and Name fields.  The one word
  750. classes are listed here:
  751.  
  752.     #define    BUTTON              0x8000
  753.     #define    EDIT                0x8100
  754.     #define    STATIC              0x8200
  755.     #define    LISTBOX             0x8300
  756.     #define    SCROLLBAR           0x8400
  757.     #define    COMBOBOX            0x8500
  758.     
  759. The lExtendedStyle DWORD is used to specify the extended style flags
  760. to be used for this control.  The extended style flags are placed at
  761. the end of the CONTROL (or other control statements) statement
  762. following the coordinates
  763.  
  764. The extra information at the end of the control data structure is
  765. currently not used, but is intended for extra information that may be
  766. needed for menu items in the future.  Usually it is zero length.
  767.  
  768. The various statements used in a dialog script are all mapped to
  769. these classes along with certain modifying styles.  The values for
  770. these styles can be found in WINDOWS.H.  All dialog controls have the
  771. default styles of WS_CHILD and WS_VISIBLE.  A list of the default
  772. styles used to make the script statements follows:
  773.  
  774.     Statement       Default Class  Default Styles
  775.     CONTROL         None           WS_CHILD|WS_VISIBLE
  776.     LTEXT           STATIC         ES_LEFT
  777.     RTEXT           STATIC         ES_RIGHT
  778.     CTEXT           STATIC         ES_CENTER
  779.     LISTBOX         LISTBOX        WS_BORDER | LBS_NOTIFY
  780.     CHECKBOX        BUTTON         BS_CHECKBOX | WS_TABSTOP
  781.     PUSHBUTTON      BUTTON         BS_PUSHBUTTON | WS_TABSTOP
  782.     GROUPBOX        BUTTON         BS_GROUPBOX
  783.     DEFPUSHBUTTON   BUTTON         BS_DEFPUSHBUTTON | WS_TABSTOP
  784.     RADIOBUTTON     BUTTON         BS_RADIOBUTTON
  785.     AUTOCHECKBOX    BUTTON         BS_AUTOCHECKBOX
  786.     AUTO3STATE      BUTTON         BS_AUTO3STATE
  787.     AUTORADIOBUTTON BUTTON         BS_AUTORADIOBUTTON
  788.     PUSHBOX         BUTTON         BS_PUSHBOX
  789.     STATE3          BUTTON         BS_3STATE
  790.     EDITTEXT        EDIT           ES_LEFT|WS_BORDER|WS_TABSTOP
  791.     COMBOBOX        COMBOBOX       None
  792.     ICON            STATIC         SS_ICON
  793.     SCROLLBAR       SCROLLBAR      None
  794.     
  795. The control text is stored in the `Name or Ordinal' format described
  796. in detail above.
  797.  
  798. 4.5 Cursor Resources
  799.  
  800. Cursor resources are very much like icon resources.  They are formed
  801. in groups with the components preceding the header.  This header also
  802. employs a fixed-length component index that allows random access of
  803. the individual components.  The structure of the cursor header is as
  804. follows:
  805.  
  806.     [Resource header (type = 12)]
  807.     
  808. struct CursorHeader {
  809.   WORD   wReserved;          // Currently zero
  810.   WORD   wType;              // 2 for cursors
  811.   WORD   cwCount;            // Number of components
  812.   WORD   padding;            // filler for DWORD alignment
  813.   };
  814.     
  815. The next portion is repeated for each component resource, and starts
  816. on a DWORD boundary.
  817.  
  818. struct ResourceDirectory {
  819.   WORD   wWidth;
  820.   WORD   wHeight;
  821.   WORD   wPlanes;
  822.   WORD   wBitCount;
  823.   DWORD  lBytesInRes;
  824.   WORD   wNameOrdinal;       // Points to component
  825.   WORD   padding;            // filler for DWORD alignment
  826.   };
  827.     
  828. Each cursor component is also similar to each icon component.  There
  829. is, however, one significant difference between the two:  cursors
  830. have the concept of a `hotspot' where icons do not.  Here is the
  831. component structure:
  832.  
  833.     [Resource header (Type = 1)]
  834.     
  835. struct CursorComponent {
  836.   short  xHotspot;
  837.   short  yHotspot;
  838.   }
  839.     [Monochrome XOR mask]
  840.     [Monochrome AND mask]
  841.     
  842. These masks are bitmaps copied from the .CUR file.  The main
  843. difference from icons in this regard is that cursors do not have
  844. color DIBs used for XOR masks like cursors.  Although the bitmaps are
  845. monochrome and do not have DIB headers or color tables, the bits are
  846. still in DIB format with respect to alignment and direction.  See the
  847. SDK Reference for more information on DIB formats.
  848.  
  849. 4.6 Bitmap Resources
  850.  
  851. Windows 32 can read two types of device-independent bitmaps.  The
  852. normal type of DIB is the Windows 3.0 DIB format.  The other type of
  853. DIB is that used for OS/2 versions 1.1 and 1.2.  The bitmap resource
  854. consists of a single device-independent bitmap and accordingly, this
  855. DIB can be of either format.  The two DIBs are distinguished by their
  856. header structures.  They both have the size of their respective
  857. structures as the first DWORD in the header.  Both these structures
  858. are documented in the Windows SDK Reference Version 3.0 volume 2,
  859. section 7.  The header structure for the normal DIB is
  860. BITMAPINFOHEADER while the OS/2 DIB header is called
  861. BITMAPCOREHEADER.  The correct size (as a DWORD) must be in the first
  862. entry of the structure.
  863.  
  864.     [Normal resource header (type = 2)]
  865.     
  866.     [BITMAPINFOHEADER or BITMAPCOREHEADER]
  867.     [Color table if not 24 bits per pixel]
  868.     [Packed-pixel bitmap]
  869.     
  870. Note that the color table is optional.  All but 24 bit color bitmaps
  871. have a color table attached next.  This table's length can be
  872. computed by 2#BitsPerPixel * 3 bytes for OS/2 bitmaps or
  873. 2#BitsPerPixel * 4 bytes for Windows bitmaps.  The bitmap image data
  874. is placed immediately following the color table.
  875.  
  876. Note that the bitmap file has an unaligned header structure
  877. (BITMAPFILEHEADER structure).  This header is not, however, stored in
  878. the resource file, as it serves only to identify the type of file
  879. (DIB or DDB).
  880.  
  881. 4.7 Font and Font Directory Resources
  882.  
  883. Font resources are different from the other types of resources in
  884. that they are not added to the resources of a specific application
  885. program.  Font resources are added to .EXE files that are renamed to
  886. be .FON files.  These files are libraries as opposed to applications.
  887.  
  888. Font resources use a resource group structure.  Individual fonts are
  889. the components of a font group.  Each component is defined by a FONT
  890. statement in the .RC file.  The group header follows all components
  891. and contains all information necessary to access a specific font.
  892. The format of a font component resource is as follows:
  893.  
  894.     [Normal resource header (type = 8)]
  895.     
  896.     [Complete contents of the .FNT file follow as the resource body -
  897.     - See the Windows SDK Reference for the format of the .FNT file]
  898.     
  899. The group header for the fonts is normally last in the .RES file.
  900. Note that unlike cursor and icon groups, the font group need not be
  901. contiguous in the .RES file.  Font declarations may be placed in the
  902. .RC file mixed with other resource declarations.  The group header is
  903. added automatically by RC at the end of the .RES file.  Programs
  904. generating .RES files must add the FONTDIR entry manually.  The group
  905. header has the following structure:
  906.  
  907.     [Normal resource header (type = 7)]
  908.     
  909.     WORD NumberOfFonts; // Total number in .RES file
  910.     
  911. The remaining data is repeated for every font in the .RES file.
  912.  
  913.     
  914. WORD fontOrdinal;
  915. struct FontDirEntry {
  916.   WORD   dfVersion;
  917.   DWORD  dfSize;
  918.   char   dfCopyright[60];
  919.   WORD   dfType;
  920.   WORD   dfPoints;
  921.   WORD   dfVertRes;
  922.   WORD   dfHorizRes;
  923.   WORD   dfAscent;
  924.   WORD   dfInternalLeading;
  925.   WORD   dfExternalLeading;
  926.   BYTE   dfItalic;
  927.   BYTE   dfUnderline;
  928.   BYTE   dfStrikeOut;
  929.   WORD   dfWeight;
  930.   BYTE   dfCharSet;
  931.   WORD   dfPixWidth;
  932.   WORD   dfPixHeight;
  933.   BYTE   dfPitchAndFamily;
  934.   WORD   dfAvgWidth;
  935.   WORD   dfMaxWidth;
  936.   BYTE   dfFirstChar;
  937.   BYTE   dfLastChar;
  938.   BYTE   dfDefaultChar;
  939.   BYTE   dfBreakChar;
  940.   WORD   dfWidthBytes;
  941.   DWORD  dfDevice;
  942.   DWORD  dfFace;
  943.   DWORD  dfReserved;
  944.   char   szDeviceName[];
  945.   char   szFaceName[];
  946.   };
  947.     
  948. 4.8 String Table Resources
  949.  
  950. These tables are constructed in blocks of 16 strings.  The
  951. organization of these blocks of 16 is determined by the IDs given to
  952. the various strings.  The lowest four bits of the ID determine a
  953. string's position in the block.  The upper twelve bits determine
  954. which block the string is in.  Each block of 16 strings is stored as
  955. one resource entry.  Each string or error table resource block is
  956. stored as follows:
  957.  
  958.     [Normal resource header (type = 6 for strings)]
  959.     
  960.     [Block of 16 strings.  The strings are Pascal style with a WORD
  961.     length preceding the string.  16 strings are always written, even
  962.     if not all slots are full.  Any slots in the block with no string
  963.     have a zero WORD for the length.]
  964.     
  965. It is important to note that the various blocks need not be written
  966. out in numerical order in the resource file.  Each block is assigned
  967. an ordinal ID.  This ID is the high 12 bits of the string IDs in the
  968. block plus one (ordinal IDs can't be zero).  The blocks are written
  969. to the .RES file in the order the blocks are encountered in the .RC
  970. file, while the CVTRES utility will cause them to become ordered in
  971. the COFF object, and hence the image file.
  972.  
  973. 4.9 Accelerator Table Resources
  974.  
  975. An accelerator table is stored as a single resource.  Multiple
  976. accelerator tables are also allowed.  The format of an accelerator
  977. table is very simple.  No header for the table is used.  Each entry
  978. in the table has a single four word entry.  The last entry in the
  979. table is flaged by the hex value 0x0080 (fFlags |= 0x0080).  Since
  980. all entries are fixed length, random access can be done because the
  981. number of elements in the table can be computed by dividing the
  982. length of the resource by eight.  Here is the structure of the table
  983. entries:
  984.  
  985.     [Normal resource header (type = 9)]
  986.     
  987. The following structure is repeated for all accelerator table
  988. entries.
  989.  
  990. struct AccelTableEntry {
  991.   WORD   fFlags;
  992.   WORD   wAscii;
  993.   WORD   wId;
  994.   WORD   padding;
  995.   };
  996.     
  997. 4.10 User Defined Resources and RCDATA
  998.  
  999. RC allows the programmer to include resources not defined in Windows.
  1000. The user may choose a name not defined as a standard type and use it
  1001. to include data that is to be used as a resource.  This data may be
  1002. taken from an external file or may be placed between BEGIN and END
  1003. statements.  As an option, the programmer can define the type as
  1004. RCDATA with the same results.
  1005.  
  1006. As might be imagined, the format of this resource is very simple
  1007. because the resource compiler knows nothing about the logical
  1008. structure of the data.  Here is the organization:
  1009.  
  1010.     [Normal resource header (type = 10 for RCDATA, named types
  1011.     represent user-defined types)]
  1012.     
  1013.     [The data from the BEGIN ...  END or from the external file is
  1014.     included without translation into the .RES file]
  1015.     
  1016. 4.11 Name Table and Error Table Resources
  1017.  
  1018. Name tables and error resources are no longer supported in the
  1019. Windows binary resource file format.
  1020.  
  1021. 4.12 Version Resources.
  1022.  
  1023. Version resources specify information that can be used by setup
  1024. programs to discover which of several versions of a program or
  1025. dynamic link library to install into the system.  There is also a set
  1026. of api's to query the version resources.  There are three major types
  1027. of information stored in version resources:  the main information in
  1028. a VS_FIXEDFILEINFO structure, Language information data in a variable
  1029. file information structure (VarFileInfo), and user defined string
  1030. information in StringFileInfo structures.  For Windows 32, the
  1031. strings within the version information resource is stored in Unicode,
  1032. providing localization of the resoruces.  Each block of information
  1033. is dword aligned.
  1034.  
  1035. The structure of a version resource is depicted by the
  1036. VS_VERSION_INFO structure.
  1037.  
  1038. VS_VERSION_INFO {
  1039.     WORD wLength;             /* Length of the version resource */
  1040.     WORD wValueLength;        /* Length of the value field for this block */
  1041.     WORD wType;               /* type of information:  1==string, 0==binary */
  1042.     WCHAR szKey[];            /* Unicode string KEY field */
  1043.     [WORD Padding1;]          /* possible word of padding */
  1044.     VS_FIXEDFILEINFO Value;   /* Fixed File Info Structure */
  1045.     BYTE Children[];      /* position of VarFileInfo or StringFileInfo data */
  1046. };
  1047.  
  1048. The Fixed File Info structure contains basic information about the
  1049. version, including version numbers for the product and file, and type
  1050. of the file.
  1051.  
  1052. typedef struct tagVS_FIXEDFILEINFO {
  1053.     DWORD dwSignature;        /* signature - always 0xfeef04bd */
  1054.     DWORD dwStrucVersion;     /* structure version - currently 0 */
  1055.     DWORD dwFileVersionMS;    /* Most Significant file version dword */
  1056.     DWORD dwFileVersionLS;    /* Least Significant file version dword */
  1057.     DWORD dwProductVersionMS; /* Most Significant product version */
  1058.     DWORD dwProductVersionLS; /* Least Significant product version */
  1059.     DWORD dwFileFlagMask;     /* file flag mask */
  1060.     DWORD dwFileFlags;        /*  debug/retail/prerelease/... */
  1061.     DWORD dwFileOS;           /* OS type.  Will always be Windows32 value */
  1062.     DWORD dwFileType;         /* Type of file (dll/exe/drv/... )*/
  1063.     DWORD dwFileSubtype;      /* file subtype */
  1064.     DWORD dwFileDateMS;       /* Most Significant part of date */
  1065.     DWORD dwFileDateLS;       /* Least Significant part of date */
  1066. } VS_FIXEDFILEINFO;
  1067.  
  1068. The user defined string information is contained within the
  1069. StringFileInfo structure, which is a set of two strings:  the key and
  1070. the information itself.
  1071.  
  1072. StringFileInfo {
  1073.     WCHAR       szKey[];      /* Unicode "StringFileInfo" */
  1074.     [WORD        padding;]    /* possible padding */
  1075.     StringTable Children[];
  1076. };
  1077.  
  1078. StringTable {
  1079.     WCHAR      szKey[];   /* Unicode string denoting the language - 8 bytes */
  1080.     String Children[];    /* array of children String structures */
  1081. }
  1082.  
  1083. String {
  1084.     WCHAR   szKey[];          /* arbitrary Unicode encoded KEY string */
  1085.                          /* note that there is a list of pre-defined keys */
  1086.     [WORD   padding;]         /* possible padding */
  1087.     WCHAR Value[];            /* Unicode-encoded value for KEY */
  1088. } String;
  1089.  
  1090. The variable file info (VarFileInfo) block contains a list of
  1091. languages supported by this version of the application/dll.
  1092.  
  1093. VarFileInfo {
  1094.     WCHAR szKey[];            /* Unicode "VarFileInfo" */
  1095.     [WORD padding;];          /* possible padding */
  1096.     Var        Children[];    /* children array */
  1097. };
  1098.  
  1099. Var {
  1100.     WCHAR szKey[];       /* Unicode "Translation" (or other user key) */
  1101.     [WORD padding;]      /* possible padding */
  1102.     WORD  Value[];       /* one or more values, normally language id's */
  1103. };
  1104.  
  1105. 4.13 Messagetable Resources.
  1106.  
  1107. A message table is a resource that contains formatted text that is
  1108. used to display an error message or messagebox.  It has taken the
  1109. place of the error table resource (which was never used).  The data
  1110. consists of a MESSAGE_RESOURCE_DATA structure, which contains one or
  1111. more MESSAGE_RESOURCE_BLOCKS, which in turn may consist of one or
  1112. more MESSAGE_RESOURCE_ENTRY structures.  The structure is similar to
  1113. that of the STRINGTABLE resource.
  1114.  
  1115. typedef struct _MESSAGE_RESOURCE_DATA {
  1116.     ULONG NumberOfBlocks;
  1117.     MESSAGE_RESOURCE_BLOCK Blocks[];
  1118. } MESSAGE_RESOURCE_DATA, *PMESSAGE_RESOURCE_DATA;
  1119.  
  1120. typedef struct _MESSAGE_RESOURCE_BLOCK {
  1121.     ULONG LowId;
  1122.     ULONG HighId;
  1123.     ULONG OffsetToEntries;
  1124. } MESSAGE_RESOURCE_BLOCK, *PMESSAGE_RESOURCE_BLOCK;
  1125.  
  1126. typedef struct _MESSAGE_RESOURCE_ENTRY {
  1127.     USHORT Length;
  1128.     USHORT Flags;
  1129.     UCHAR Text[];
  1130. } MESSAGE_RESOURCE_ENTRY, *PMESSAGE_RESOURCE_ENTRY;
  1131.  
  1132. If the Flags USHORT is MESSAGE_RESOURCE_UNICODE (value 0x0001), the
  1133. string is encoded in UNICODE rather than ASCII in the current
  1134. codepage.
  1135.